import { useLatest, usePrevious } from "@/hooks/useLatest";
import { Button } from "antd";
import React, { useState } from "react";

const UseLatest: React.FC = () => {
  const [count, setCount] = useState<number>(1);
  const latestValue = useLatest<number>(count);
  const previousValue = usePrevious<number>(count);

  return (
    <>
      <h4>最新的值：{latestValue}</h4>
      <h4>旧的值：{previousValue}</h4>
      <h5>count值：{count}</h5>
      <Button onClick={() => setCount(c => c + 1)}>+1</Button>
    </>
  );
};
export default UseLatest;
